package net.com.hydroPK.net.packethandler;

import net.com.hydroPK.Engine;
import net.com.hydroPK.model.Player;
import net.com.hydroPK.model.combat.PlayerMagic;
import net.com.hydroPK.model.misc.PlayerMethods;

/*
 *
 * By Zach Noel <z_noel@hotmail.com>
 *
 */

public class MagicOnPlayer {

    Player p;

    public MagicOnPlayer(Player p) {
        this.p = p;
        PlayerMethods playerMethods = new PlayerMethods(p);

        p.enemyIndex = p.stream.readSignedWordBigEndian();
        int oppIndex = p.stream.readSignedWordBigEndian();
        int spellbook = p.stream.readUnsignedWord();
        Player opp = Engine.players[oppIndex];
        p.clickId = p.stream.readUnsignedWord();

        if (p.isDead || opp.isDead) {
            return;
        }
        playerMethods.setAttackPlayer(false);
        p.playerMagic.combatMagic(opp, spellbook, p.clickId);
    }

}